<?php
class db{
	/*
	 * "mysql" Banco de dados MySQL
         * "pg" Banco de dados PostgreSQL
	 */

        static $sgbd     = "mysql";
	
	static $database = "esw_conbrad";
	static $server   = "localhost";
	static $username = "conbrad_site";
	static $passwd   = "YTdkNTA0OWM3ODEyYzZi";
        
	static function conecta(){
		switch(db::$sgbd){
			case "mysql":
				$conexao = mysql_connect(db::$server, db::$username, db::$passwd);
				mysql_select_db(db::$database);
			break;
                        case "pg":
                                $conexao = pg_connect("host=".db::$server." port=5432 dbname=".db::$database." user=".db::$username." password=".db::$passwd);
                        break;
		}
                return $conexao;
	}
	
	static function query($sql, $conexao){
		switch(db::$sgbd){
			case "mysql":
				return mysql_query($sql, $conexao);
			break;
                        case "pg":
                                return pg_exec($conexao, $sql);
                        break;
		}
	}
	
	static function fetch_array($result){
		switch(db::$sgbd){
			case "mysql":
				return mysql_fetch_array($result);
			break;
                        case "pg":
				return pg_fetch_array($result);
			break;
		}
	}
	
	static function close($conexao){
		switch(db::$sgbd){
			case "mysql":
				return mysql_close($conexao);
			break;
                        case "pg":
				return pg_close($conexao);
			break;
		}
	}
}
?>
